Skip to content

Improve orDominator #12272

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 29, 2021
Merged

Improve orDominator #12272

merged 2 commits into from
Apr 29, 2021

Conversation

odersky
Copy link
Contributor

@odersky odersky commented Apr 29, 2021

Merge applied type arguments also for abstract and opaque type constructors

Fixes #12264

odersky added 2 commits April 29, 2021 12:12
Merge applied type arguments also for abstract and opaque type constructors

Fixes scala#12264
@@ -343,7 +343,12 @@ object TypeOps:

tp match {
case tp: OrType =>
approximateOr(tp.tp1, tp.tp2)
(tp.tp1.dealias, tp.tp2.dealias) match
case (tp1 @ AppliedType(tycon1, args1), tp2 @ AppliedType(tycon2, args2))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While this addresses the most common issue, I don't think that's enough to handle things like Tag[Long] | (Tag[Int] & SomeTrait) or type Tag2[X] <: Tag[X]; Tag[Long] | Tag2[Int]. But to properly deal with all possible cases it seems that we'd need a generalization of baseClasses that also returns base abstract types.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since what we do here is an approximation anyway, I'd leave that under possible future improvement.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good to me.

@@ -343,7 +343,12 @@ object TypeOps:

tp match {
case tp: OrType =>
approximateOr(tp.tp1, tp.tp2)
(tp.tp1.dealias, tp.tp2.dealias) match
case (tp1 @ AppliedType(tycon1, args1), tp2 @ AppliedType(tycon2, args2))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good to me.

@odersky odersky merged commit e4151a4 into scala:master Apr 29, 2021
@odersky odersky deleted the fix-12264 branch April 29, 2021 13:27
@Kordyjan Kordyjan added this to the 3.0.1 milestone Aug 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Type infers widens union of applied abstract covariant types F[A] | F[B] into Any instead of F[A | B]
3 participants